package org.aphelie.romancer.util;

import org.aphelie.romancer.util.message.Messager;
import org.aphelie.romancer.util.message.impl.MessagerImpl;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public abstract class AbstractRomancerUIPlugin extends AbstractUIPlugin{
	
	private Messager messager;
	
	protected AbstractRomancerUIPlugin() {
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		registerMessager();
	}
	
	public void stop(BundleContext context) throws Exception {
		unregisterMessager();
		super.stop(context);
	}
	
	
	// MESSAGES //
	protected Messager getMessager() {
		if (messager == null) {
			messager = (Messager) new MessagerImpl(this);
		}
		return messager;
	}
	
    protected abstract void registerMessager();
    
    protected abstract void unregisterMessager();
    

	public String getString(String key) {
		return getMessager().getString(key);
	}

}
